//
//  MyButton.m
//  makepack_tools
//
//  Created by tangs on 2018/8/22.
//  Copyright © 2018年 tangs. All rights reserved.
//

#import "MyButton.h"

@implementation MyButton

- (void)drawRect:(NSRect)dirtyRect {
    [super drawRect:dirtyRect];
    // Drawing code here.
}

- (void)onSwitch:(id)sender {
    if (self.data != nil) {
        if (self.state == NSControlStateValueOn) {
            [self.data replaceObjectAtIndex:0 withObject:[[NSNumber alloc] initWithBool:YES]];
        } else {
            [self.data replaceObjectAtIndex:0 withObject:[[NSNumber alloc] initWithBool:NO]];
        }
    }
}

- (void)bindData:(NSMutableArray *)data {
    self.data = data;
    [self setTarget:self];
    [self setAction:@selector(onSwitch:)];
}

@end
